<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改书本')" />
</head>
<body class="white-bg">
<form class="form-horizontal m" id="form-user-update" th:object="${user}">

    <div class="form-group">
        <label class="col-sm-3 control-label is-required">id：</label>
        <div class="col-sm-8">
            <input class="form-control" type="text" name="id" readonly id="id" th:field="*{id}"  required>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label is-required">邮箱：</label>
        <div class="col-sm-8">
            <input class="form-control" type="text" name="email" id="email" th:field="*{email}"  required>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label is-required">密码：</label>
        <div class="col-sm-8">
            <input class="form-control" type="text"  readonly name="password" id="password" th:field="*{password}" required>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label">昵称：</label>
        <div class="col-sm-8">
            <input class="form-control" type="text" id="nickname" th:field="*{nickname}" name="nickname">
        </div>
    </div>


    <div class="form-group">
        <label class="font-noraml">性别</label>
        <select class="form-control"  th:field="*{sex}">
            <option value="0">男</option>
            <option value="1">女</option>
        </select>
    </div>

    <div class="form-group">
        <label class="col-sm-3 control-label">头像地址：</label>
        <div class="col`-sm-8">
            <input class="form-control" type="text" id="avatar_url"  th:field="*{avatar_url}" name="avatar_url">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label">openid：</label>
        <div class="col-sm-8">
            <input class="form-control" type="text" id="openid"  th:field="*{openid}" name="openid">
        </div>
    </div>
</form>

<th:block th:include="include :: footer" />
<script type="text/javascript">
		var prefix = ctx + "book/user";

		$("#form-user-update").validate({
			rules:{
				dictSort:{
					digits:true
				},
			},
			focusCleanup: true
		});

		function submitHandler() {
		console.log("submit..");
	        if ($.validate.form()) {

	        	$.operate.save(prefix + "/update", $('#form-user-update').serialize(),function(data){
	        	console.log("update success");
	        	console.log(data);
	        	$.operate.successCallback(data);
	        	});
	        }
	        else
	        {
	            console.log("validate fail");
	        }
	    }


	</script>

</body>
</html>